package com.example.test.util;

import cn.hutool.core.util.RandomUtil;
import lombok.experimental.UtilityClass;
import org.apache.shiro.crypto.hash.Md5Hash;
import org.apache.shiro.crypto.hash.Sha1Hash;

@UtilityClass
public class EncryptUtil {
    public String md5Hash(String plaintext, String salt, Integer iterationNum) {
        return new Md5Hash(plaintext, salt, iterationNum).toString();
    }

    public String sha1Hash(String plaintext, String salt, Integer iterationNum) {
        return new Sha1Hash(plaintext, salt, iterationNum).toString();
    }

    public static void main(String[] args) {
        String salt = RandomUtil.randomString(10);
        System.out.println(salt);
        System.out.println(md5Hash("123", salt,2));
    }
}
